package com.xfcy.content.feign;

import com.xfcy.content.model.po.CourseIndex;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author 晓风残月Lx
 * @date 2023/7/3 16:45
 */
@Component
@Slf4j
public class SearchServiceClientFallbackFactory implements FallbackFactory<SearchServiceClient> {

    @Override
    public SearchServiceClient create(Throwable throwable) {
        return new SearchServiceClient() {
            @Override
            public Boolean add(CourseIndex courseIndex) {
                log.debug("添加课程索引发生熔断，索引信息：{}, 熔断异常：{}", courseIndex, throwable.toString(), throwable);
                // 走降级返回false
                return false;
            }
        };
    }
}
